<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
session_start();
include_once("../config.inc.php");
include_once(__Modules_Path."/JSon.lib.php");

$arrGameID = explode(",", __LottoUsePower);

$strUserData = stripcslashes($_data["UserData"]);

$strCheckKey = base64_encode($strUserData)."##".$_data["PFSID"]."==".urlencode($_data["Link"])."||".$_data["PFHost"]."[".date("Y-m-d")."]";
$strCheckKey = md5($strCheckKey);
if($strCheckKey !== $_data["CheckKey"])exit("Check Key Error!! ( ".$strCheckKey." != ".$_data["CheckKey"]." )");

if($_data["PFSID"] != $_SESSION["Member_PFSID"]){
	$_SESSION["Member_PFSID"] = $_data["PFSID"];
}

$objJS = new Services_JSON();
$objUser = $objJS -> decode($strUserData);

$strCKey = $objUser -> ID."_".(string)(md5(time() + mt_rand(0, 10000)));
setcookie("Member_CKey", $strCKey);
$_SESSION["Member_Info"] -> CKey = $strCKey;

$_SESSION["Member_Info"] -> ID = $objUser -> ID;
$_SESSION["Member_Info"] -> Account = $objUser -> UserAcc;
$_SESSION["Member_Info"] -> Name = $objUser -> UserName;
$_SESSION["Member_Info"] -> MemberGroup = $objUser -> UserGroup;
$_SESSION["Member_Info"] -> ParentID = $objUser -> ParentID;
$_SESSION["Member_Info"] -> isShowAllReport = $objUser -> isShowAllReport;
$_SESSION["Member_Info"] -> isSupple = 1;//$objUser -> isSupple;
$_SESSION["Member_Info"] -> isLock = $objUser -> UserStatus;
$_SESSION["Member_Info"] -> SpGroup = $objUser -> SpGroup;
$_SESSION["Member_Info"] -> DomainName = $_SERVER["HTTP_HOST"];
$_SESSION["Member_Info"] -> ERID = $objUser -> UserExID;
$_SESSION["Member_Info"] -> ExRecordID = $objUser -> ExRecordID;
$_SESSION["Member_Info"] -> ExRate = $objUser -> ExRate;
$_SESSION["Member_Info"] -> ExName = $objUser -> ExName;
$_SESSION["Member_Info"] -> SubID = $objUser -> Layer2ID;
$_SESSION["Member_Info"] -> MainID = $objUser -> Layer3ID;
$_SESSION["Member_Info"] -> StockID = $objUser -> Layer4ID;
$_SESSION["Member_Info"] -> DirectorID = $objUser -> Layer5ID;
$_SESSION["Member_Info"] -> Layer6ID = $objUser -> Layer6ID;
$_SESSION["Member_Info"] -> GambleType = $objUser -> GLine;
$_SESSION["Member_Info"] -> CreditLine = $objUser -> CreditLine;
//將群組資訊存入 session
$_SESSION["Member_Info"] -> GroupName = $objUser -> GroupName;

$_SESSION["Member_Info"] -> GameIDPower = (array)$objUser -> GameIDPower;
$_SESSION["Member_Info"] -> GamePower = (array)$objUser -> GamePower;

$_SESSION["Member_PFSID_Time"] = time();
$_SESSION["RdHttpHost"] = $_data["PFHost"];


switch($_data["LanguageCode"]){
	case "zh-tw":
		$_SESSION["Mem_LanguageNo"] = 1;
		$_SESSION["Mem_Charset"] = "big5";
		break;

	case "en":
		$_SESSION["Mem_LanguageNo"] = 2;
		$_SESSION["Mem_Charset"] = "iso-8859-1";
		break;

	case "zh-cn":
	default:
		$_SESSION["Mem_LanguageNo"] = 3;
		$_SESSION["Mem_Charset"] = "gb2312";
		break;
}

header("Location: ".$_data["Link"]);
?>